# models/sys_api_project.py
from sqlalchemy import Column, String, Integer, DateTime, Boolean, Text
from src.core.ormdb import Base
from src.core import str_utils as strU


class SysApiProject(Base):
    __tablename__ = 'sys_api_project'
    __table_args__ = {'comment': 'API项目'}

    id = Column(String(36), primary_key=True, default=lambda: strU.generate_id(), comment="唯一标识ID")
    org_id = Column(String(36), nullable=True, comment='组织ID')
    # api_id = Column(String(36), nullable=True, comment='API主键')
    api_key = Column(String(36), default=lambda: strU.secret_key(), comment='API KEY')
    api_code = Column(String(36), nullable=True, comment='API代码')
    api_name = Column(String(36), nullable=True, comment='API名称')
    api_description = Column(String(128), nullable=True, comment='API说明')
    invite_code = Column(String(36), nullable=True, comment='邀请码')
    is_activate = Column(Integer, default=1, comment='启用，1：启用，0：停用')
    disable_date = Column(DateTime, nullable=True, comment='停用时间')
    deletion_mark = Column(Integer, default=0, comment='删除标志，0 表示未删除，1 表示已删除')
    deletion_reason = Column(String(255), nullable=True, comment='删除原因')
    deletion_date = Column(DateTime, nullable=True, comment='删除日期')
    deletion_by = Column(String(255), nullable=True, comment='删除者')
    create_date = Column(DateTime, default=lambda: strU.now(), comment='创建日期')
    creator_by = Column(String(255), nullable=True, comment='创建者')
    last_updated_date = Column(DateTime, nullable=True, comment='最后更新时间')
    last_updated_by = Column(String(255), nullable=True, comment='最后更新者')
